css target Link- from react

93

The proper React way would be to wrap the React Router Link with your own component that applies styles.
------
import { Link as RouterLink } from 'react-router-dom';

function Link(props) {
    return <RouterLink className="myClassname" {...props} />;
}

export default Link;
---------
Then you can use your Link component just as you would the native Link component and the class name will be applied automatically.

For a quicker, dirtier approach, the React Router Link object is simply an <a> tag under the hood. In a global stylesheet, you can simply target a to apply styles.

Comments

Submit
0 Comments